package com.example.controller;

import com.example.interceptor.Auth;
import com.example.model.ClassTableRelation;
import com.example.model.ClassTableRelationVO;
import com.example.service.ClassTableRelationService;
import com.example.service.LabService;
import com.example.util.DataMap;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created with IntelliJ IDEA.
 * User: tao95
 * Date: 2017/5/11
 * Time: 22:57
 * To change this template use File | Settings | File Templates.
 * Description:
 */

@Auth
@Controller
@RequestMapping("ctr")
@Api(value = "ClassTableRelation",tags = "课程表管理类")
public class ClassTableRelationController {
    @Autowired
    private ClassTableRelationService ctrServiceImpl;
    @Autowired
    private LabService labServiceImpl;
    @RequestMapping(value = {"/ctrList"})
    public ModelAndView ctrList(Integer laboratoryId ,Integer daysId){
        //显示课程表的模块，可根据实验室id和星期进行筛选
        ModelAndView model = new ModelAndView();
        ClassTableRelation classTableRelation = new ClassTableRelation();
        classTableRelation.setLaboratoryId(laboratoryId);
        classTableRelation.setDaysId(daysId);
        DataMap dataMap = labServiceImpl.selectLabList();
        model = ctrServiceImpl.findTimeTable(classTableRelation, model);
        model.setViewName("list");
        model.addObject("labList",dataMap.get("labList"));
        return model;
    }
    @RequestMapping(value = {"/addCTR"})
    public String addCTR(ClassTableRelationVO classTableRelation){
        //增加课程表的模块
        DataMap dataMap = new DataMap();
        dataMap = ctrServiceImpl.addCTR(classTableRelation);
        return "forward:/main";
    }
    @RequestMapping(value = {"/delCTR"})
    public String delCTR(Integer id){
        //删除课程表模块
        DataMap dataMap = ctrServiceImpl.delCTR(id);
        return "forward:/main";
    }
}